package cn.itcast.springbook.controller;

//import cn.itcast.springbook.config.JdbcProperties;
import cn.itcast.springbook.config.PersonProperties;
import cn.itcast.springbook.pojo.User;
import cn.itcast.springbook.service.UserService;
import com.alibaba.druid.support.spring.stat.SpringStatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.jws.soap.SOAPBinding;
import javax.sql.DataSource;

/**
 * @author 21195
 * @version v1.0
 * @package cn.itcast.springbook.controller
 * @description:
 * @date 2019/6/10 19:31
 *
 * RestController和Controller区别
 * 就是内置了@ResponseBody注解，这样我们的方法返回json的时候就不用加@ResponseBody
 **/

@RestController
public class HelloController {

//    @Autowired
//    private JdbcProperties jdbcProperties;

//   @Autowired
//    private DataSource dataSource;

   @Autowired
   private UserService userService;

   @Autowired
   private PersonProperties personProperties;
    @GetMapping("/hello")
    public String hello(){
//        System.out.println(jdbcProperties);
//        System.out.println(dataSource);
        System.out.println(personProperties);
        return "hello springbook!";
    }
    @GetMapping("/hello/{id}")
    public User hello(@PathVariable Long id){
        User user = userService.queryById(id);
        System.out.println("user = " + user);
        return user;
    }

}
